﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

using System.Data.Common;
using Mocola.BLL;
using Mocola.Model;

namespace Mocola.Net.Web.ajax
{
    public partial class GetProject : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(Request.QueryString["id"]))
            {
                string ProjectID = Request.QueryString["id"];
                using (IDataReader reader = Databases.MocolaNet.Select(Moc_ProjectInfo.Moc_Project,
                   Moc_ProjectInfo.Moc_Project.ProjectID,
                   Moc_ProjectInfo.Moc_Project.Name,
                   Moc_ProjectInfo.Moc_Project.PlaceName,
                   Moc_ProjectInfo.Moc_Project.PlotName,
                   Moc_ProjectInfo.Moc_Project.CaseName,
                   Moc_ProjectInfo.Moc_Project.OldName1,
                   Moc_ProjectInfo.Moc_Project.OldName2,
                   Moc_ProjectInfo.Moc_Project.NameChiose,
                   Moc_ProjectInfo.Moc_Project.Character1,
                   Moc_ProjectInfo.Moc_Project.Character2,
                   Moc_ProjectInfo.Moc_Project.Character3,
                   Moc_ProjectInfo.Moc_Project.Structure,
                   Moc_ProjectInfo.Moc_Project.StartTime,
                   Moc_ProjectInfo.Moc_Project.EndTime,
                   Moc_ProjectInfo.Moc_Project.State,
                   Moc_ProjectInfo.Moc_Project.PlaceArea,
                   Moc_ProjectInfo.Moc_Project.OvergroundArea,
                   Moc_ProjectInfo.Moc_Project.BlewgroundArea,
                   Moc_ProjectInfo.Moc_Project.TotalArea,
                   Moc_ProjectInfo.Moc_Project.JrArea,
                   Moc_ProjectInfo.Moc_Project.Corps,
                   Moc_ProjectInfo.Moc_Project.ConstructUnit,
                   Moc_ProjectInfo.Moc_Project.DesignUnit,
                   Moc_ProjectInfo.Moc_Project.IntendanceUnit,
                   Moc_ProjectInfo.Moc_Project.Address,
                   Moc_ProjectInfo.Moc_Project.Remark,
                   Moc_ProjectInfo.Moc_Project.CharacterZdy)
                   .Where(Moc_ProjectInfo.Moc_Project.ProjectID == Convert.ToInt32(ProjectID))
                   .ToDataReader())
                {
                    string Datastring = string.Empty;
                    Response.Write("{\"Moc_Project\":[ {");

                    while (reader.Read())
                    {
                        int ProjectID2 = reader.GetInt32(0);
                        string Name = reader.GetString(1);
                        string PlaceName = reader.GetString(2);
                        string PlotName = reader.GetString(3);
                        string CaseName = reader.GetString(4);
                        string OldName1 = reader.GetString(5);
                        string OldName2 = reader.GetString(6);
                        int NameChiose = reader.GetInt32(7);
                        string Character1 = reader.GetString(8);
                        string Character2 = reader.GetString(9);
                        string Character3 = reader.GetString(10);
                        string Structure = reader.GetString(11);
                        string StartTime = reader.GetString(12);
                        string EndTime = reader.GetString(13);
                        int State = reader.GetInt32(14);
                        int PlaceArea = reader.GetInt32(15);
                        int OvergroundArea = reader.GetInt32(16);
                        int BlewgroundArea = reader.GetInt32(17);
                        int TotalArea = reader.GetInt32(18);
                        int JrArea = reader.GetInt32(19);
                        string Corps = reader.GetString(20);
                        string ConstructUnit = reader.GetString(21);
                        string DesignUnit = reader.GetString(22);
                        string IntendanceUnit = reader.GetString(23);
                        string Address = reader.GetString(24);
                        string Remark = reader.GetString(25);
                        string CharacterZdy = reader.GetString(26);

                        Response.Write("\"ProjectID\":" + ProjectID + ",");
                        Response.Write("\"Name\":\"" + Name + "\",");
                        Response.Write("\"PlaceName\":\"" + PlaceName + "\",");
                        Response.Write("\"PlotName\":\"" + PlotName + "\",");
                        Response.Write("\"CaseName\":\"" + CaseName + "\",");
                        Response.Write("\"OldName1\":\"" + OldName1 + "\",");
                        Response.Write("\"OldName2\":\"" + OldName2 + "\",");
                        Response.Write("\"NameChiose\":" + NameChiose + ",");
                        Response.Write("\"Character1\":\"" + Character1 + "\",");
                        Response.Write("\"Character2\":\"" + Character2 + "\",");
                        Response.Write("\"Character3\":\"" + Character3 + "\",");
                        Response.Write("\"Structure\":\"" + Structure + "\",");
                        Response.Write("\"StartTime\":\"" + StartTime + "\",");
                        Response.Write("\"EndTime\":\"" + EndTime + "\",");
                        Response.Write("\"State\":" + State + ",");
                        Response.Write("\"PlaceArea\":" + PlaceArea + ",");
                        Response.Write("\"OvergroundArea\":" + OvergroundArea + ",");
                        Response.Write("\"BlewgroundArea\":" + BlewgroundArea + ",");
                        Response.Write("\"TotalArea\":" + TotalArea + ",");
                        Response.Write("\"JrArea\":" + JrArea + ",");
                        Response.Write("\"Corps\":\"" + Corps + "\",");
                        Response.Write("\"ConstructUnit\":\"" + ConstructUnit + "\",");
                        Response.Write("\"DesignUnit\":\"" + DesignUnit + "\",");
                        Response.Write("\"IntendanceUnit\":\"" + IntendanceUnit + "\",");
                        Response.Write("\"Address\":\"" + Address + "\",");
                        Response.Write("\"Remark\":\"" + Remark + "\",");
                        //Response.Write("\"CharacterZdy\":\"" + Remark + "\"");
                        Response.Write("\"CharacterZdy\":\"" + CharacterZdy + "\"");
                    }

                    Response.Write("} ]}");
                }
            }
        }
    }
}
